@extends('common.admin-master')
@section('html-header')
    <link rel="stylesheet" type="text/css" href="{{url('/css/admin/common.css')}}">
@endsection

@section('html-body')
<div class="content">
    <div class="header">
        <h3 class="page-title">审核服务商</h3>
    </div>
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="well">
                <div id="myTabContent" class="tab-content">
                    <div class="tab-pane active in" id="home" style="margin-left: 40%">
                        <label style="margin-left: 80px"><img src="{{route('Api.OrgPhoto.Show',['id'=>$fac->user_id])}}"> </label>
                       <ul class="fansinfo" style="list-style: none">
                           <li><em>昵称：</em><span>{{$fac->nickname}}</span></li>
                           <li><em>真实姓名：</em><span>{{$fac->realname}}</span></li>
                           <li><em>地区：</em><span>{{$fac->province}}-{{$fac->city}}-{{$fac->area}}</span></li>
                           <li><em>联系电话：</em><span>{{$fac->telephone}}</span></li>
                           <li><em>联系QQ：</em><span>{{$fac->qq}}</span></li>
                           <li><em>联系邮箱：</em><span>{{$fac->email}}</span></li>
                           <li><em>身份证号：</em><span>{{$fac->card_num}}</span></li>
                           <li><em>身份证正面：</em><span><img width="180px" height="109px" src="{{route('Api.Cardf.Show',['id'=>$fac->user_id])}}"><a href="{{route('Api.Cardf.Show',['id'=>$fac->user_id])}}" target="_blank">查看原图</a></span></li>
                           <li><em>身份证反面：</em><span><img width="180px" height="109px" src="{{route('Api.Cardb.Show',['id'=>$fac->user_id])}}"><a href="{{route('Api.Cardb.Show',['id'=>$fac->user_id])}}" target="_blank">查看原图</a></span></li>
                       </ul>
                        <div style="margin-left: 80px;margin-top: 20px">
                            @if((int)$fac->state == 1)
                                <button class="btn btn-primary save"><i class="icon-ok"></i> 通过</button>
                                <button class="btn btn-primary eventBtn"><i class="icon-remove"></i> 不通过</button>
                            @elseif((int)$fac->state == 3)
                                <button class="btn btn-primary" disabled><i class="icon-remove"></i>审核不通过</button>
                            @elseif((int)$fac->state == 0)
                                <button class="btn btn-primary" disabled><i class="icon-ok"></i>待用户提交审核</button>
                            @elseif((int)$fac->state == 2)
                                <button class="btn btn-primary" disabled><i class="icon-ok"></i>审核已通过</button>
                            @endif
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div  class="pop" style="display: none;">
    请告诉TA不通过的原因：
    <p><textarea id="msg"></textarea><button id="btn_send">反馈</button></p>
</div>
<div class="mirror"  style="display: none;"></div>
<script>
    jQuery(function() {
        var doc = document,
                $doc = $(doc);

        function toggle() {
            $(".pop").toggle();
            $(".mirror").toggle();
        }

        $doc.on("click", ".eventBtn", function() {
            toggle();
        });

        $doc.on("click", ".mirror", function() {
            toggle();
        });

        $doc.on("click", ".pop button", function() {
            toggle();
        });

        jQuery.ajaxSetup({
            case:false,
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });

        $doc.on('click','.save',function(){
            $.ajax({
                type:"post",
                url:"{{route('Api.Admin.setFacPass')}}",
                dataType:"json",
                data:{
                    "facid":'{{$fac->id}}'
                },
                success:function(obj){
                    if(obj.level === "success"){
                        noty({text:obj.message,type:obj.level,timeout:800,
                            callback:{
                                afterClose:function(){
                                    location.reload();
                                }
                            }
                        });
                    }
                },
                error:function(obj){
                    var datajson = obj.responseJSON;
                    noty({text:datajson.message,type:datajson.level,timeout:800});
                }
            });
        });

        $doc.on('click','#btn_send',function(){
            var msg = $('#msg').val();
            $.ajax({
                type:"post",
                url:"{{route('Api.Admin.facNoPass')}}",
                dataType:"json",
                data:{
                    "facid":'{{$fac->id}}',
                    "msg":msg
                },
                success:function(obj){
                    if(obj.level === "success"){
                        noty({text:obj.message,type:obj.level,timeout:800,
                            callback:{
                                afterClose:function(){
                                    location.reload();
                                }
                            }
                        });
                    }
                },
                error:function(obj){
                    var datajson = obj.responseJSON;
                    noty({text:datajson.message,type:datajson.level,timeout:800});
                }
            });
        });
    });
</script>
@endsection


